#!/usr/bin/env bash
# Summary: Remove JDK installations
# Usage: jenv remove alias-name+
set -e
[ -n "$JENV_DEBUG" ] && set -x

# Provide jenv completions
if [ "$1" = "--complete" ]; then
  exec jenv-versions --bare
fi


for jenv_version in "$@"
do
  JENV_VERSION=${jenv_version}

  if [ -L "$JENV_ROOT/versions/$JENV_VERSION" ];
  then
    rm -f $JENV_ROOT/versions/$JENV_VERSION
    rm -f ${JENV_ROOT}/$JENV_VERSION.time
    echo "JDK $JENV_VERSION removed"

  else
    echo "$JENV_VERSION is not a managed version of Java "
  fi
done

$(jenv-rehash)
